package com.anXin.user.service.impl;

import com.anXin.apis.equipment.IEquipmentClient;
import com.anXin.gpt.ChatSparkDesk;
import com.anXin.model.common.dtos.ResponseResult;
import com.anXin.model.common.enums.AppHttpCodeEnum;
import com.anXin.model.user.pojos.Memo;
import com.anXin.model.user.pojos.Oldman;
import com.anXin.model.user.pojos.Report;
import com.anXin.model.user.pojos.User;
import com.anXin.user.mapper.MemoMapper;
import com.anXin.user.mapper.ReportMapper;
import com.anXin.user.service.MemoService;
import com.anXin.user.service.OldmanService;
import com.anXin.user.service.ReportService;
import com.anXin.user.service.UserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import utils.thread.AppThreadLocalUtil;

import javax.annotation.Resource;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.LinkedHashMap;
import java.util.List;


@Service
public class MemoServiceImpl extends ServiceImpl<MemoMapper, Memo> implements MemoService {


    @Override
    public ResponseResult add(Memo memo) {
        if (memo.getPlanTime()==null)return ResponseResult.errorResult(AppHttpCodeEnum.PARAM_REQUIRE);
        if (memo.getMemo()==null)return ResponseResult.errorResult(AppHttpCodeEnum.PARAM_REQUIRE);
        boolean save = save(memo);
        if (save)return ResponseResult.okResult(AppHttpCodeEnum.SUCCESS);
        return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR);
    }

    @Override
    public ResponseResult getList(Long id) {
        List<Memo> list = query().eq("oldman_id", id).orderByAsc("plan_time").list();
        if (list.isEmpty())return ResponseResult.okResult(AppHttpCodeEnum.DATA_LIST_NULL);
        return ResponseResult.okResult(list);
    }

    @Override
    public ResponseResult Info(Long id) {
        Memo memo = query().eq("id", id).one();
        return ResponseResult.okResult(memo);
    }

    @Override
    public ResponseResult delete(Long id) {
        boolean removeById = removeById(id);
        if (removeById)return ResponseResult.okResult(AppHttpCodeEnum.SUCCESS);
        return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR);
    }

    @Override
    public ResponseResult updateMemo(Memo memo) {
        boolean updateById = updateById(memo);
        if (updateById)return ResponseResult.okResult(AppHttpCodeEnum.SUCCESS);
        return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR);
    }
}